﻿ $(document).ready(function(){
        $('#send_message').click(function(e){
            
            //Stop form submission & check the validation
            //e.preventDefault();
            
            // Variable declaration
            var error = false;
            var name = $('#name').val();
            var pwd = $('#pwd').val();
            //var lab1 = $('#lab1').val();
            var email = $('#email').val();
            var tel = $('#tel').val();
            var xing = $('#xing').val();
            var pwd2 = $('#pwd2').val();
            
         	// Form field validation
            if(name.length == 0){
                var error = true;
                $('#name_error').fadeIn(500);
            }else{
                $('#name_error').fadeOut(500);
            }
            if(pwd.length == 0){
                var error = true;
                $('#pwd_error').fadeIn(500);
            }else{
                $('#pwd_error').fadeOut(500);
            }
            if(pwd.length == 0 || !(pwd.trim() == pwd2.trim())){
                var error = true;
                $('#pwd2_error').fadeIn(500);
            }else{
                $('#pwd2_error').fadeOut(500);
            }
            

            
            if(email.length == 0 || email.indexOf('@') == '-1'){
                var error = true;
                $('#email_error').fadeIn(500);
            }else{
                $('#email_error').fadeOut(500);
            }
                 
            if(tel.length == 0){
                var error = true;
                $('#tel_error').fadeIn(500);
            }else{
                $('#tel_error').fadeOut(500);
            }

                                     


             

            
            // If there is no validation error, next to process the mail function
            if(error == false){
            	alert("您确定要注册码！");
            		return true;	
            	
            	
            }
            return false;
        });    
    });